﻿using System.Xml.Linq;

namespace _030泛型_部分类_枚举_结构体_9结构体类型
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Student student1 = new Student(ID : 101, Name : "lili");
            //装箱 此时把student实例丢到内存堆中,obj引用着student的实例
            //Object obj = student;
            ////拆箱
            //Student student2 = (Student)obj;
            Student student2 = student1;
            student2.Name = "chengzi";
            student2.ID = 102;
            //浅拷贝  要是类的话会把地址传给student2  此时改变后值都会变
            Console.WriteLine($"#{student1.ID}Name:{student1.Name}");
            Console.WriteLine($"#{student2.ID}Name:{student2.Name}");
            student1.Speak();
            //结构体实现接口

        }
    }

    interface ISpeak
    {
        void Speak();
    }
    //结构体只能继承接口 不能派生基类型 和类类型  
    struct Student : ISpeak
    {
        //结构体不支持显式的 无参 构造器 只支持 有参 构造器
        public Student(int ID,string Name)
        {
            this.ID = ID;
            this.Name = Name;
        }
        public int ID { get; set; }
        public string Name { get; set; }

        public void Speak() {
            Console.WriteLine("Hello");
        }
    }

    //struct Student
    //{
    //    public int ID { get; set; }
    //    public string Name { get; set; }
    //}
}
